package gzip;

import java.io.*;
import java.util.zip.GZIPInputStream;

import org.junit.Test;

public class GZipReaderTest {

    @Test
    public void testReadGZipFile() {
        String dictFile = "C:\\test\\av.dict.dz";
        int bufferSize = 5000; // 50KB cache
        byte[] content = new byte[bufferSize];
        try {
            GZIPInputStream reader = (GZIPInputStream) makeInputStream(dictFile);
            reader.read(content, 100, 500);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        String string = new String(content);
        System.out.println(string);

    }

    private BufferedReader constructReader(String filePath) throws IOException {
        InputStream is = makeInputStream(filePath);
        InputStreamReader streamReader = new InputStreamReader(is);
        return new BufferedReader(streamReader);
    }
    
    private InputStream makeInputStream(String filePath) throws IOException {
        FileInputStream fis = new FileInputStream(filePath);
        BufferedInputStream bis = new BufferedInputStream(fis);
        return new GZIPInputStream(bis);
    }

}
